From: Tim Starling Date: Sat, 26 Nov 2005 05:36:34 +0000 (+0000) Subject: Bounded execution time and memory for image thumbnailing X-Git-Tag: 1.6.0~1129 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=1c93c62945b42a1d5db949eb0d4c3f1a2d1d2b84;p=lhc%2Fweb%2Fwiklou.git Bounded execution time and memory for image thumbnailing --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index b4be6488ae..d97740eba9 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1584,12 +1584,16 @@ function wfIsWellFormedXmlFragment( $text ) { function wfShellExec( $cmd ) { global $IP; + if ( php_uname( 's' ) == 'Linux' ) { $time = ini_get( 'max_execution_time' ); $mem = ini_get( 'memory_limit' ); if ( $time > 0 && $mem > 0 ) { - $memKB = intval( $mem / 1024 ); - $cmd = escapeshellarg( "$IP/bin/ulimit.sh" ) . " $time $memKB $cmd"; + $script = "$IP/bin/ulimit.sh"; + if ( is_executable( $script ) ) { + $memKB = intval( $mem / 1024 ); + $cmd = escapeshellarg( $script ) . " $time $memKB $cmd"; + } } } return shell_exec( $cmd ); diff --git a/includes/Image.php b/includes/Image.php index 8d3709a21d..c1ca2187d6 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -1036,7 +1036,7 @@ class Image wfEscapeShellArg( $thumbPath ) ), $wgSVGConverters[$wgSVGConverter] ); wfDebug( "reallyRenderThumb SVG: $cmd\n" ); - $conv = shell_exec( $cmd ); + $conv = wfShellExec( $cmd ); } else { $conv = false; } @@ -1049,7 +1049,7 @@ class Image wfEscapeShellArg($this->imagePath) . " -resize {$width}x{$height} " . wfEscapeShellArg($thumbPath); wfDebug("reallyRenderThumb: running ImageMagick: $cmd\n"); - $conv = shell_exec( $cmd ); + $conv = wfShellExec( $cmd ); } else { # Use PHP's builtin GD library functions. #